package com.wenhuitec.productlib.ui.activity;

import android.content.Context;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.gzwh.weblib.bean.NzProductAttrModel;
import com.gzwh.weblib.bean.NzProductCategory;
import com.gzwh.weblib.bean.Result;
import com.gzwh.weblib.utils.MyObserver;
import com.gzwh.weblib.utils.RequestUtils;
import com.wenhuitec.productlib.R;
import com.wenhuitec.productlib.ui.adapter.CategoryManagerAdapter;
import com.wenhuitec.productlib.ui.adapter.MenuCategoryAdapter;
import com.wenhuitec.productlib.ui.adapter.attr.AttrCateAdapter;
import com.wenhuitec.productlib.ui.adapter.sku.SkuEditAdapter;
import com.wenhuitec.sysui.TitleBuilder;

import java.util.ArrayList;
import java.util.List;

public class AttrEditActivity extends AppCompatActivity {

    private Context mContext;

    private RecyclerView attCategoryRv;

    private CategoryManagerAdapter mCategoryManagerAdapter;

    private AttrCateAdapter attrCateAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_product_attr);
        this.mContext = this;
        new TitleBuilder(this)
                .setTitleText("口味做法")
//                .setLeftIco(R.drawable.yp)
                .setLeftIcoListening((view) -> finish());
        attCategoryRv = findViewById(R.id.attCategoryRv);

    }

    @Override
    public void onResume() {
        super.onResume();
        RequestUtils.getAttrList(mContext, new MyObserver<List<NzProductAttrModel>>(mContext, false) {
            @Override
            public void onSuccess(Result<List<NzProductAttrModel>> result) {
                System.out.println(result.toString());
                attCategoryRv.setLayoutManager(new LinearLayoutManager(mContext));//设置布局管理器
                attrCateAdapter = new AttrCateAdapter(mContext, result.getResult());
                attCategoryRv.setAdapter(attrCateAdapter);
            }

            @Override
            public void onFailure(Throwable e, String errorMsg) {

            }
        });
    }

}
